#include <stdint.h>
/* LED灯1亮 */
extern void LED1_On(void);
/* LED灯1灭 */
extern void LED1_Off(void);
/* LED灯2亮 */
extern void LED2_On(void);
/* LED灯2灭 */
extern void LED2_Off(void);

/* 把同一个灯的操作封装起来 */
struct tagLEDFuncCB {
    void (*LedOn)(void);
    void (*LedOff)(void);
};

/* 定义需要操作到的灯的表 */
const static struct tagLEDFuncCB LedOpTable[] = {
        {LED1_On, LED1_Off},
        {LED2_On, LED2_Off},
};

void LED_Ctrl(void) {
    static uint32_t sta = 0;
    uint8_t i;

    for (i = 0; i < sizeof(LedOpTable) / sizeof(LedOpTable[0]); i++)    {
        (sta == i) ? (LedOpTable[i].LED_On()) : (LedOpTable[i].LED_Off());
    }

    /* 跑下个灯 */
    sta = (sta + 1) % (sizeof(LedOpTable) / sizeof(LedOpTable[0]));
}

int main(void){
    while (1)    {
        LED_Ctrl();
        os_delay(200);
    }
}
